﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;



public struct Timer
{
    public float currentTime;
    public float maxTime;
    public bool Tick(float deltaTime)
    {
        if(currentTime>maxTime)
        {
            Reset();
            return true;
        }
        else
        {
            currentTime += deltaTime;
            return false;
        }
    }
    public Timer(float initMaxTime)
    {
        currentTime = 0;
        maxTime = initMaxTime;
    }
    public void Reset()
    {
        currentTime = 0;
    }

    public bool IsTimerFinish(float time)
    {
        return currentTime > time;
    }

}


/// <summary>
/// Ticker主要是
/// </summary>
public struct Ticker {
    //在用来进行帧优化时，随机初始
    private static System.Random r = new System.Random();
    public int currentTick;
    public int maxTick;
    public bool Tick()
    {
        if(currentTick>=maxTick)
        {
            currentTick = 0;
            return true;
        }
        else
        {
            currentTick++;
            return false;
        }
    }
    public Ticker(int maxTick,bool RandomInitTick)
    {
        this.maxTick = maxTick;
        currentTick = RandomInitTick? r.Next(maxTick): 0;
    }
}
